<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/app.css">
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
</head>
<body>
<!--
    制作者：九哥
    页面：员工面试详情页面
    时间：2019-09-29
-->





<!----------员工面试详情页面---------->
<div id="jobShowPage"><!--此ID页面切换用-->
    <div id="jobShowTitle">
        <b>岗位需求详情</b>
        <img src="../../images/return.png" id="jobShowRtn"
             onclick="history.go(-1);">
    </div>
    <div id="jobShowDetail">
        <table>
            <tr>
                <td width="60">
                    <span id="head"></span>
                </td>
                <td>
                    <p>联系人：
                        <span id="contact"></span>
                    </p>
                    <p>招聘电话：
                        <span id="telephone"></span>
                    </p>
                    <p>招聘工种：
                        <span id="jobName"></span>
                    </p>
                    <p>招聘性别：
                        <span id="sexName"></span>
                    </p>
                </td>
            </tr>
        </table>
        <div style="height:10px;background:#f8f8f8;"></div>
        <div class="detail">
            <p>
                公司名称：
                <span id="cname"></span>
            </p>
            <!--<p style="border-bottom:1px solid #f8f8f8;">-->
                <!--<img src="../../images/locate.png" width="8">-->
                <!--所在地区-->
                <!--<span style="float:right;" id="address"></span>-->
            <!--</p>-->
            <p style="border-bottom:1px solid #f8f8f8;">
                <img src="../../images/locate.png" width="8">
                所在地区：
                <span id="address"></span>
            </p>
            <p>
                需要人数：
                <span id="num"></span>
                <br><br>
                薪资：
                <span id="emolument"></span>
                <br><br>
                招聘待遇：
                <span id="welfare"></span>
                <br><br>
                学历要求：
                <span id="eduName"></span>
                <br><br>
                工作年限：
                <span id="workYear"></span>
                <br><br>
                工作时间：
                <span id="workHour"></span>
                <br><br>
                邮箱地址：
                <span id="email"></span>
                <br><br>
                年龄区间：
                <span id="ageRange"></span>
            </p>
            <b>岗位介绍</b>
            <p>
                <span id="detail"></span>
            </p>
            <b>需要技能</b>
            <p>
                <span id="skill"></span>
            </p>
            <b>岗位内容</b>
            <p>
                <span id="content"></span>
            </p>
            <!--工人操作按钮-->
            <!--1工人投递中，2企业拒绝投递，3企业面试邀请，4工人拒绝邀请，5面试中，-->
            <!--6面试失败，7面试成功，8工人评价，9企业评价，10完成-->
            <p class="submit">
                招聘流程状态：【<span id="statusName"></span>】
                <br><br>
                <button onclick="getTalk()">去交流</button>
                &nbsp; &nbsp;
                <button class="grey">已投递</button>
                <br><br>
                <span id="meet"></span>
                <br><br>
                <span id="finish"></span>
                <br><br>
                <span id="comment"></span>
            </p>
            <br><br><br>
        </div>
    </div>
</div>
<input type="hidden" id="cid" value="0">
<input type="hidden" id="job" value="0">
<!----------员工面试详情页面---------->





<!----------面试评价弹窗---------->
<div class="popComment">
    <div class="mask"></div>
    <div class="detail">
        <h2>面试评价</h2>
        <p>评价等级：</p>
        <p>
            <select id="level">
                <option value="1">差评</option>
                <option value="2">一般</option>
                <option value="3">好评评</option>
            </select>
        </p>
        <p>评价内容：</p>
        <p>
            <textarea id="commentDetail" cols="30" rows="10"></textarea>
        </p>
        <p>
            <button onclick="$('.popComment').hide()">取消</button>
            &nbsp;
            <button onclick="setCommentAdd()">保存</button>
        </p>
    </div>
</div>
<!----------面试评价弹窗---------->





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->
</body>
<script type="text/javascript" src="../../js/app.js"></script>
<script type="text/javascript" src="../../js/cache.js"></script>
</html>


<script type="text/javascript">
    (function(){
        getShowList();
        //延时一秒判断
        setTimeout(function(){
            getComment();
        }, 1000);
    })();
    //岗位列表
    function getShowList(){
        var userInfo = cacheGet('userInfo');
        var id = getUrlParam('staffJobId');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            id:id
        };
        $.ajax({
            type:'post',
            url:getDomain()+'/show',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',2);
                    console.log(res);
                    return
                }
                console.log(res.data);
                var resData = res.data;
                var head = '<img src="../../images/toux01.png" width="40">';
                if (resData.head!='') {
                    head = '<img src="'+resData.head+'" width="40">';
                }
                $('#cid')[0].value = resData.cid;
                $('#cname').html(resData.cname);
                $('#contact').html(resData.contact);
                $('#head').html(head);
                $('#job')[0].value = resData.job;
                $('#jobName').html(resData.jobName);
                $('#sexName').html(resData.sexName);
                $('#telephone').html(resData.telephone);
                $('#address').html(resData.address);
                $('#emolument').html(resData.emolument);
                $('#welfare').html(resData.welfare);
                $('#num').html(resData.num);
                $('#workYear').html(resData.workYear);
                $('#workHour').html(resData.workHour);
                $('#ageRange').html(resData.ageRange);
                $('#email').html(resData.email);
                $('#eduName').html(resData.eduName);
                if (resData.detail) {
                    $('#detail').html(resData.detail);
                } else {
                    $('#detail').html('没有');
                }
                if (resData.skill) {
                    $('#skill').html(resData.skill);
                } else {
                    $('#skill').html('没有');
                }
                if (resData.content) {
                    $('#content').html(resData.content);
                } else {
                    $('#content').html('没有');
                }
                //招聘状态
                var status = resData.status;
                var statuss = resData.statuss;
                $('#statusName').html(statuss[status]);
                //按钮判断
//                1工人投递中，2企业拒绝投递，3企业面试邀请，4工人拒绝邀请，5面试中，
//                6面试失败，7面试成功，8工人评价，9企业评价，10完成
                var meet = '', finish = '', comment = '';
                if (status==1) {
                    meet += '<button class="grey">拒绝邀请</button>';
                    meet += ' &nbsp; &nbsp; ';
                    meet += '<button class="grey">接受邀请</button>';
                    finish += '<button class="grey">面试失败</button>';
                    finish += ' &nbsp; &nbsp; ';
                    finish += '<button class="grey">面试成功</button>';
//                    comment += '<button class="grey">待评价</button>';
                    comment += '<button onclick="setComment()">待评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#meet').html(meet);
                    $('#finish').html(finish);
                    $('#comment').html(comment);
                } else if (status==3) {
                    meet += '<button onclick="setMeet(1)">拒绝邀请</button>';
                    meet += ' &nbsp; &nbsp; ';
                    meet += '<button onclick="setMeet(2)">接受邀请</button> ';
                    finish += '<button class="grey">面试失败</button>';
                    finish += ' &nbsp; &nbsp; ';
                    finish += '<button class="grey">面试成功</button>';
                    comment += '<button class="grey">待评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#meet').html(meet);
                    $('#finish').html(finish);
                    $('#comment').html(comment);
                } else if (status==5) {
                    meet += '<button class="grey">拒绝邀请</button>';
                    meet += ' &nbsp; &nbsp; ';
                    meet += '<button class="grey">接受邀请</button>';
                    finish += '<button onclick="setFinish(1)">面试失败</button>';
                    finish += ' &nbsp; &nbsp; ';
                    finish += '<button onclick="setFinish(2)">面试成功</button> ';
                    comment += '<button class="grey">待评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#meet').html(meet);
                    $('#finish').html(finish);
                    $('#comment').html(comment);
                } else if (status==7) {
                    meet += '<button class="grey">拒绝邀请</button>';
                    meet += ' &nbsp; &nbsp; ';
                    meet += '<button class="grey">接受邀请</button>';
                    finish += '<button class="grey">面试失败</button>';
                    finish += ' &nbsp; &nbsp; ';
                    finish += '<button class="grey">面试成功</button>';
                    comment += '<button onclick="setCommet()">去评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#meet').html(meet);
                    $('#finish').html(finish);
                    $('#comment').html(comment);
                } else if (status>8) {
                    meet += '<button class="grey">拒绝邀请</button>';
                    meet += ' &nbsp; &nbsp; ';
                    meet += '<button class="grey">接受邀请</button>';
                    finish += '<button class="grey">面试失败</button>';
                    finish += ' &nbsp; &nbsp; ';
                    finish += '<button class="grey">面试成功</button>';
                    comment += '<button class="grey">已评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#meet').html(meet);
                    $('#finish').html(finish);
                    $('#comment').html(comment);
                }
            }
        });
    }
    //去交流，工人可看
    function getTalk(){
        var cid = $('#cid').val();
        var userInfo = cacheGet('userInfo');
        var jobId = getUrlParam('job');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            uid2:cid,
            job:jobId
        };
        $.ajax({
            type:'post',
            url:'/api/msg/add',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',2);
                    console.log(res);
                    return
                }
                var resData = res.data;
//                console.log(resData);
                var talkId = resData.talkId;
                var own = resData.own;
                var other = resData.other;
                var otherName = resData.otherName;
                var jobId = resData.jobId;
                var prefix = '?id='+talkId+'&own='+own+'&other='+other+'&otherName='+otherName+'&jobId='+jobId;
                window.location.href = '/h5/message/jobWin.html'+prefix;
            }
        });
    }
//    //去申请，工人可申请
//    function getApply(){
//        var cid = $('#cid').val();
//        var userInfo = cacheGet('userInfo');
//        var jobId = getUrlParam('job');
//        var formData = {
//            app_access:app_access,
//            token:userInfo.token,
//            cid:cid,
//            job:jobId
//        };
//        $.ajax({
//            type:'post',
//            url:'/api/home/recruit/resume-add',
//            data:formData,
//            success: function (res) {
//                //console.log(res); return
//                if (res.code==-41) {
//                    console.log(res);
//                    getAppErrMsg('您的简历早已发送！','',0);
//                    return
//                } else if (res.code!=0) {
//                    console.log(res);
//                    getAppErrMsg(res.msg,'',0);
//                    return
//                }
//                var resData = res.data;
//                getAppErrMsg('发送成功！','',0);
//            }
//        });
//    }
    /**
     * 设置接受邀请
     * 1拒绝邀请，2接受邀请
     * */
    function setMeet(v){
//        getAppErrMsg('待接入！','',0)
        var userInfo = cacheGet('userInfo');
        var jobId = getUrlParam('staffJobId');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            job:jobId,
            meet:v
        };
        $.ajax({
            type:'post',
            url:'/api/my/job/meet-set',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',0);
                    console.log(res);
                    return
                }
                getAppErrMsg(res.msg,'',0);
                console.log(res);
                setTimeout(function(){
                    window.location.href = '';
                }, 1000*2);
            }
        });
    }
    /**
     * 设置面试完成
     * 1面试失败，2面试成功
     * */
    function setFinish(v){
//        getAppErrMsg('待接入！','',0)
        var userInfo = cacheGet('userInfo');
        var jobId = getUrlParam('staffJobId');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            job:jobId,
            finish:v
        };
        $.ajax({
            type:'post',
            url:'/api/my/job/finish-set',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',0);
                    console.log(res);
                    return
                }
                getAppErrMsg(res.msg,'',0);
                console.log(res);
                setTimeout(function(){
                    window.location.href = '';
                }, 1000*2);
            }
        });
    }
    //显示评价
    function setComment(){
        $('.popComment').show();
    }
    //设置评价
    function setCommentAdd(){
        var userInfo = cacheGet('userInfo');
        var jobId = getUrlParam('staffJobId');
        var level = $('#level').val();
        var detail = $('#commentDetail').val();
        if (!level || !detail) {
            getAppErrMsg('信息不全！','',0);
            return
        }
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            job:jobId,
            level:level,
            detail:detail
        };
//        console.log(formData); return
        $.ajax({
            type:'post',
            url:'/api/my/job/recruit/comment-set',
            data:formData,
            success: function (res) {
                //console.log(res); return
                if (res.code!=0) {
                    getAppErrMsg(res.msg,'',0);
                    console.log(res);
                    return
                }
                getAppErrMsg(res.msg,'',0);
                console.log(res);
                setTimeout(function(){
                    window.location.href = '';
                }, 1000*2);
            }
        });
    }
    //获取评价
    function getComment(){
//        getAppErrMsg('待接入！','',0)
        var userInfo = cacheGet('userInfo');
        var jobId = getUrlParam('staffJobId');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            job:jobId
        };
        $.ajax({
            type:'post',
            url:'/api/my/job/recruit/comment-get',
            data:formData,
            success: function (res) {
                //console.log(res); return
                var comment = '';
                if (res.code!=0) {
                    comment += '<button onclick="setComment()">待评价</button>';
                    comment += ' &nbsp; &nbsp; ';
                    comment += '<button class="grey">完成</button>';
                    $('#comment').html(comment);
                    console.log(res);
                    return
                }
                comment += '<button class="grey">已评价</button>';
                comment += ' &nbsp; &nbsp; ';
                comment += '<button class="grey">完成</button>';
                $('#comment').html(comment);
            }
        });
    }
    //请求地址
    function getDomain(){
        return '/api/my/job/staff';
    }
</script>